package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.DevelopFailedRecord;
import cn.wolfcode.crm.mapper.DevelopFailedRecordMapper;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.IDevelopFailedRecordService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class DevelopFailedRecordImpl implements IDevelopFailedRecordService {
    @Autowired
    private DevelopFailedRecordMapper failedRecordMapper;

    public void saveOrUpdate(DevelopFailedRecord entity) {
            failedRecordMapper.insert(entity);
    }


    public PageResult query(QueryObject qo) {
        int count = failedRecordMapper.queryCount(qo);
        if (count == 0) {
            return new PageResult(0, Collections.emptyList());
        }
        List<DevelopFailedRecord> failedRecords = failedRecordMapper.queryList(qo);
        return new PageResult(count, failedRecords);
    }
}
